package com.project.controller;

import io.swagger.annotations.Api;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@Api(tags="计算租用车位时间工具类")
public class TimeCalcu {
    public static double timeCalcu(String time){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startTime = null;
        try {
            startTime = format.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(startTime);
        long stTime = startTime.getTime();
        Date endTime = new Date();
        System.out.println(endTime);
        long enTime = endTime.getTime();
        System.out.println(enTime);
        double dt = enTime-stTime;
        System.out.println(dt);
        int dt2 = (int)((dt/(1000*60*60))*100);
        System.out.println(dt2);
        double resTime = dt2/100.0;
        System.out.println(resTime);
        return resTime;
    }
    public static double timeCalcu2(Date time1,Date time2){
        System.out.println(time1);
        System.out.println(time2);
        long stTime = time1.getTime();
        System.out.println(stTime);
        long enTime = time2.getTime();
        System.out.println(enTime);
        double dt = enTime-stTime;
        System.out.println(dt);
        int dt2 = (int)((dt/(1000*60*60))*100);
        System.out.println(dt2);
        double resTime = dt2/100.0;
        System.out.println(resTime);
        return resTime;
    }
}
